﻿#region Copyright
//       Copyright (c) 2009 - Antoine Jaussoin - http://www.jaussoin.com/blog/
// 
//        This program is free software: you can redistribute it and/or modify
//        it under the terms of the GNU General Public License as published by
//        the Free Software Foundation, either version 3 of the License, or
//        (at your option) any later version.
// 
//        This program is distributed in the hope that it will be useful,
//        but WITHOUT ANY WARRANTY; without even the implied warranty of
//        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//        GNU General Public License for more details.
// 
//        You should have received a copy of the GNU General Public License
//        along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FT.Architecture.Example.Console.Benchmark
{
    public class BenchmarkEngine
    {
        public void RunMultiple(params BenchmarkBase[] benchmarks)
        {
            foreach (var benchmark in benchmarks)
            {
                var result = benchmark.RunBenchmark();
                System.Console.Out.WriteLine("[{0}] {1} objects, {2}ms",benchmark.Name,result.Items.Count, result.Timer.TotalElapsed);
                foreach (var evt in result.Timer.Events)
                {
                    System.Console.Out.WriteLine("\t+{1}ms\t+{2}ms\t{0}", 
                        evt.EventDescription, 
                        evt.ElapsedSinceLastEvent.ToString("N0").PadLeft(5,' '),
                        evt.ElapsedSinceStart.ToString("N0").PadLeft(5, ' '));
                }
            }
        }
    }
}
